var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
var Data = require('../../utils/data.js');
var common = require("../../utils/common.js")  
var page_size=50,page = 1,keyword='',that;  

var GetList = function (that) {  
	common.wxshowLoading();
	Data.httpGet(
    { action: 'getAccountInfoList', page_size:page_size,page:page,ora_quantity:1},
	 		 function (res) {
	 			var l = that.data.list;
	 			//console.log(l.length);
	 			if(l.length>=res.data.source.recordCount){
	 				common.wxhideLoading();
	 				return false;
	 			}
	 			var res = res.data;
	 			for (var i = 0; i < res.data.length; i++) {
	 		        l.push(res.data[i])  
	 		    }
	 			//console.log(l);
	 			that.setData({  
	 		        list: l  
	 		    });  
	 			page++;  
	 			common.wxhideLoading();
	 		 }
	  );
}

Page({

  /**
   * 页面的初始数据
   */
  data: {
	  list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
	  that = this;
	  wx.setNavigationBarTitle({
	     	 title: '排行榜'
	  });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
	  GetList(that);
  },

  onPullDownRefresh: function () {
	    //下拉  
	    page = 1;
	    that.setData({  
	      list: [],  
	    });
	    GetList(that)
	    wx.stopPullDownRefresh();
  },
	
  onReachBottom: function () {
	    //上拉  
	    GetList(that) 
  }
})